Technical Q&A

PPCSYS 08 - NewRoutineDescriptor & Porting 68K code to PPC (1-June-96)


Q I'm trying to port my 68K code to PPC. I have custom functions defined for calling ModalDialog. Here's what my code looked like:
ModalDialog((ModalFilterProcPtr) MyFilter, &itemNum);

The compiler complained that it cannot covert my custom function to type RoutineDescriptor*, so I changed it by casting it to RoutineDescriptor:

ModalDialog((RoutineDescriptor*) MyFilter, &itemNum);

There were no compile or link errors, but now, when I run the program, it crashes with a type 3 error.

What's the correct way to implement this?

A Create a UPP using NewRoutineDescriptor instead of casting to a UPP. In Dialogs.h there is a macro for NewRoutineDescriptor called NewModalFilterProc. Your code should look like this:
ModalFilterUPP myFilterUPP;
myFilterUPP = NewModalFilterProc(MyFilter);
ModalDialog(myFilterUPP,  &itemNum);

See Also

  • See Using Universal Procedure Pointers in Inside Macintosh: PPC System Software, page 2-21, for more information.


Technical Q&A
Previous Question | Contents